package Excle.PubliceExcelUtils;


import cn.afterturn.easypoi.excel.entity.ImportParams;
import typeConversion.typeDo.GoodsListFileInfoBO;

import java.io.File;
import java.util.List;

/**
 * @author yangjicong
 * @date 2022/9/17
 * 可以参考o2o-aggregate-base-service 中的适用方式
 */
public class RunExcelUtils {

    public static void main(String[] args) throws Exception {
        testReadFile();
    }


    public static void testReadFile() throws Exception {
        long start = System.currentTimeMillis();
        File file = new File("D:\\Develop\\StudySpease\\StudyFile\\活动商品导入模板v2压测.xlsx");
        byte[] bytes = FileReaderUtils.readRandomAccess(file);
        long l = System.currentTimeMillis();
        long FileTime =  l - start;
        System.out.println("文件读取执行了" + FileTime);
        // 公共解析excel(缺点就是无法读取上面有合并格式单元格的excel文件)
        List<GoodsListFileInfoBO> importList = ExcelUtils.importExcel(bytes, GoodsListFileInfoBO.class,new ImportParams());
        long end = System.currentTimeMillis();
        long time = end - l;

        System.out.println("文件解析执行了" + time +" 毫秒");
        System.out.println("文件列表为: " + importList +"\n"+"总条数为:  "+ importList.size());

        //byte[] baa = ExcelUtils.exportExcel(importList, GoodsListFileInfoBO.class);

        //生成本地文件,并且只能为xls文件或者为csv文件
        //File file1 = FileUtil.byte2File(baa, "C:\\Users\\旧巷里的少年郎\\Desktop", "11111.xls");
        //File file1 = FileUtil.byte2File(baa, "C:\\Users\\旧巷里的少年郎\\Desktop", "222.csv");
    }



}
